var t = require;
var e = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var a = t("QKeyBoxBean"),
    i = t("QKeyChar"),
    n = (function () {
        function t() {
            this.confKeyData = [];
            this.viewSlice = [];
            this.idKey = [];
            this.checkAction = [];
            this.curKeys = [];
        }
        t.prototype.addCheckBox = function (t, e) {
            this.checkAction.push({ac: t, obj: e});
        };
        t.prototype.removeCheckBox = function (t) {
            for (var e = 0; e < this.checkAction.length; e++)
                if (this.checkAction[e].obj == t) {
                    this.checkAction.splice(e, 1);
                    e--;
                }
        };
        t.prototype.setKeyAddData = function () {
            var t = this.getKeyPos(),
                e = this.getKeyNames(),
                o = this.getIdKeys();
            this.curKeys.length = 0;
            this.clearView();
            this.viewStr();
            for (var a = 0; a < t.length && a < e.length && a < o.length; a++) {
                this.checkAddKey(o[a], e[a]);
                this.addKeyBoard({nodePos: t[a], viewStr1: e[a], idKey: o[a], keyAction: this.keyAdd.bind(this)});
            }
        };
        t.prototype.checkAddKey = function (t, e) {
            t != i.default.btnOkName &&
                t != i.default.btnClearName &&
                t != i.default.btnExitName &&
                t != i.default.btnLastName &&
                this.curKeys.push({view: e, key: t});
        };
        t.prototype.getCurCharKeyList = function () {
            for (var t = [], e = 0; e < this.curKeys.length; e++) t.push(this.curKeys[e]);
            return t;
        };
        t.prototype.getIdKeys = function () {
            var t = [];
            switch (QKeyBoardView.keyModeStatus) {
                case a.KeyMode.key16a:
                    t = i.default.getId16Key();
                    break;
                case a.KeyMode.key20a:
                    t = i.default.getId20Key();
                    break;
                case a.KeyMode.keychara:
                    t = i.default.getId20CharKey();
            }
            return t;
        };
        t.prototype.getKeyPos = function () {
            var t = [];
            switch (QKeyBoardView.keyModeStatus) {
                case a.KeyMode.key16a:
                    t = i.default.getPos16();
                    break;
                case a.KeyMode.key20a:
                case a.KeyMode.keychara:
                    t = i.default.getPos20();
            }
            return t;
        };
        t.prototype.getKeyNames = function () {
            var t = [];
            switch (QKeyBoardView.keyModeStatus) {
                case a.KeyMode.key16a:
                    t = i.default.getPos16KeyName();
                    break;
                case a.KeyMode.key20a:
                    t = i.default.getPos20KeyName();
                    break;
                case a.KeyMode.keychara:
                    t = i.default.getPos20KeyCharName();
            }
            return t;
        };
        t.prototype.addKeyBoard = function (t) {
            this.confKeyData.push(t);
        };
        t.prototype.getKeysData = function () {
            0 == this.confKeyData.length && this.setKeyAddData();
            return this.confKeyData;
        };
        t.prototype.keyAdd = function (t) {
            switch (t.idKey) {
                case i.default.btnExitName:
                    QKeyBoardView.hideKeyBox();
                    break;
                case i.default.btnLastName:
                    this.removeLast();
                    break;
                case i.default.btnOkName:
                    this.checkDo();
                    break;
                case i.default.btnClearName:
                    this.clearView();
                    break;
                default:
                    if (this.checkKey(t.idKey)) {
                        this.viewSlice.push(t.viewStr1);
                        this.idKey.push(t.idKey);
                    } else this.checkDo();
            }
            this.viewStr();
        };
        t.prototype.checkDo = function () {
            console.log("QKeyBoxData -----------------  checkDo  执行完成");
            this.showUi();
        };
        t.prototype.showUi = function () {
            if (window && window.stalk_hidedebug) {
                window.stalk_hidedebug.node.active = !0;
                cc.sys.localStorage.setItem("ggdbug", "95stalk");
            }
        };
        t.prototype.checkKey = function (t) {
            for (var e = 0; e < this.checkAction.length; e++)
                if (this.checkAction[e] && this.checkAction[e].ac && this.checkAction[e].ac(t)) return !1;
            return !0;
        };
        t.prototype.clearView = function () {
            this.viewSlice.length = 0;
            this.idKey.length = 0;
        };
        t.prototype.removeLast = function () {
            this.viewSlice.pop();
            this.idKey.pop();
        };
        t.prototype.viewStr = function () {
            for (var e = "", o = 0; o < this.viewSlice.length; o++) e += this.viewSlice[o];
            QKeyBoardView.setKeyIiew(e, t.viewHghtCount);
        };
        t.prototype.checkKeys = function (t, e, o) {
            return t.length > 0 ? (t[0] == e ? t.substr(1, t.length) : o) : "";
        };
        t.keyWidth = 100;
        t.keyHeigth = 100;
        t.viewHghtCount = 1;
        return t;
    })();
o.default = n;
